<template>
    <div class="photoinfo-container">
        <!-- 大标题 -->
        <h3 class="title">{{ photoimgs.title }}</h3> 
        <!-- 子标题 -->
        <p class="subtitle">
            <span>发表时间:{{ photoimgs.add_time  | dateFormat }}</span>
            <span>点击{{ photoimgs.click }}次</span>
        </p>
        <hr>
        <!-- 缩略图区域 -->
        <div class="preview">
            <vue-preview :slides="list" @close="handleClose"></vue-preview>
        </div>

        <!-- 内容区域 -->
        <div class="content" v-html="photoimgs.content" ></div>

        <!-- 评论子组件区域 -->
        <cmt-box :id="id"></cmt-box>

    </div>
</template>

<script>
    // 导入评论子组件
    import comment from '../subcomponents/comment.vue'
export default {
    data(){
        return{
            id :　this.$route.params.id,//网址中传来的id
            photoimgs:{}, //图片评论数据数组
            list:[]//图片缩略图数据
        }
    },
    created(){
        this.getphotoimgs();
        this.getthumimages();
    },
    methods:{
        getphotoimgs(){
            this.$http.get("http://www.liulongbin.top:3005/api/getimageinfo/" + this.id).then(result=>{
                if(result.body.status === 0){
                    this.photoimgs = result.body.message[0]
                }
            })
        },
        getthumimages(){
            this.$http.get("http://www.liulongbin.top:3005/api/getthumimages/" + this.id).then(result=>{
                if(result.body.status === 0){
                    result.body.message.forEach(item => {
                        item.msrc = item.src;
                        item.w = 600;
                        item.h = 400;
                    });
                    this.list = result.body.message;
                }
            })
        }
    },
    components:{ // 注册子组件
        'cmt-box': comment
    }
}
</script>
<style lang="scss" scoped>
.photoinfo-container{
    padding: 0 5px; 
    .title{
        font-size: 15px;
        text-align: center;
        margin: 10px 0;
        color: #26a2ff;
    }

    .subtitle{
        display: flex;
        font-size: 13px;
        justify-content: space-between;
    }
}
</style>
